<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!-- 核心标签是最常用的JSTL标签 -->
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%><!-- 包含一系列标准函数,大部分 是通用的字符串处理函数 -->
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><!-- 格式化并输出文本、日期、时间、数字 -->
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
<head>
<title>房间数据统计2 </title>
<base href="<%=basePath%>" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="apple-touch-icon-precomposed" href="i/app-icon72x72@2x.png">
<meta name="apple-mobile-web-app-title" content="Amaze UI" />
<link rel="stylesheet" href="layui/css/layui.css" media="all">
<link rel="stylesheet" href="css/MyCSS.css">
<!-- 适应所有设备 -->
<style type="text/css">
html, body {
	height: 100%;
	margin: 0;
	padding: 0;
}
</style>
</head>
<body>
			<div class="layui-tab layui-tab-card" lay-filter="statData">
				<ul class="layui-tab-title">
					<li class="layui-this" lay-id="1">3D捕鱼</li>
					<li lay-id="2">哪吒闹海</li>
					<li lay-id="3">打地鼠</li>
					<li lay-id="4">水浒传</li>
					<li lay-id="5">拉霸机</li>
				</ul>
				<div class="layui-tab-content">
					<div class="layui-tab-item layui-show">
						<table class="layui-table"  lay-filter="statRoom" id="statRoom">
					</div>
					<div class="layui-tab-item">
						<table class="layui-table"  lay-filter="statRoom" id="statRoom">
					</div>
					<div class="layui-tab-item">
						<table class="layui-table"  lay-filter="statRoom" id="statRoom">
					</div>
					<div class="layui-tab-item">
						<table class="layui-table"  lay-filter="statRoom" id="statRoom">
					</div>
					<div class="layui-tab-item">
						<table class="layui-table"  lay-filter="statRoom" id="statRoom">
					</div>
				</div>
			</div>
			<br/>
	
	<script src="js/jquery.min.js"></script>
	<script src="layui/layui.js"></script>
	<script>
	  layui.use(['layer','table','element','form'],function(){
        var layer = layui.layer
  	    ,table = layui.table
  	    ,element = layui.element
  	    ,form = layui.form;
        if($(".layui-tab-title .layui-this").attr("lay-id") == 1){
        table.render({
        	elem:'#statRoom',
        	url:'stat/RoomData2',
        	method:'POST',
        	height:'full-200',
        	totalRow:true,
        	id:'Alltable',
        	where:{
        		room:$(".layui-tab-title .layui-this").attr("lay-id")
        	},
        	cols:[[
  			  {
  			    field : 'Name',
				title : '道具名称',
				hide: false
  			  }, {
    		    field : 'TotalGain',
  				title : '总获得',
  				hide: false
    		  }, {
    		    field : 'GainByFishingKill',
  			    title : '捕鱼掉落获得',
  			    hide: false
    		  }, {
    			field : 'GainByFishingBonus',
  			    title : '奖金鱼抽奖获得',
  			    hide: false
    		  }, {
    			field : 'GainByOther',
  				title : '其他玩法获得',
  				hide: false
    		  }, {
    			field : 'TotalCost',
  				title : '总消耗',
  				hide: false
    		  }, {
    			field : 'CostByFishingShoot',
  				title : '捕鱼开炮消耗',
  				hide: false
    		}]],
    		page:false,
    		response : {
				statusCode : 200
			//重新规定成功的状态码为 200，table 组件默认为 0
			},
			parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code" : res.status, //解析接口状态
					"msg" : res.message, //解析提示文本
					"count" : res.count, //解析数据长度
					"data" : res.data
				//解析数据列表
				};
			}
        });
        }
        
        
      //监听选项卡切换
        element.on('tab(statData)',function(data){
        	//3D捕鱼
        	if(data.index == 0){
        	table.reload('Alltable',{
        		where:{
        			room:$(".layui-tab-title .layui-this").attr("lay-id")
        		},
        		done:function(res){
        			var tables = $("#statRoom").next().find(".layui-table-box");
        			tables.find("[data-field='CostByFishingShoot']").css("display","false");
        		},
        		page:false
              });
              return false;
        	}
        	//2D捕鱼
        	if(data.index == 1){
        		/* console.log($("th"));
        		console.log(document.getElementById("statRoom"));
        		console.log(document.getElementById("statRoom").getElementsByTagName("tr")); */
        		table.reload('Alltable',{
            		where:{
            			room:$(".layui-tab-title .layui-this").attr("lay-id")
            		},
            		done:function(res){
            			var tables = $("#statRoom").next().find(".layui-table-box");
            			tables.find("[data-field='GainByFishingKill']").css("display","none");
            			tables.find("[data-field='GainByFishingBonus']").css("display","none");
            			tables.find("[data-field='GainByOther']").css("display","none");
            			tables.find("[data-field='CostByFishingShoot']").css("display","none");
            		},
            		page:false
                  });
                  return false;
            	}
        	//打地鼠
        	if(data.index == 2){
        		table.reload('Alltable',{
            		where:{
            			room:$(".layui-tab-title .layui-this").attr("lay-id")
            		},
            		done:function(res){
            			var tables = $("#statRoom").next().find(".layui-table-box");
            			tables.find("[data-field='GainByFishingKill']").css("display","");
            			//打爆地鼠
            			tables.find("[data-field='GainByFishingKill']").find("span")[0].innerHTML = "打爆地鼠";
            			tables.find("[data-field='GainByFishingBonus']").css("display","");
            			//砸金蛋 
            			tables.find("[data-field='GainByFishingBonus']").find("span")[0].innerHTML = "砸金蛋";
            			tables.find("[data-field='GainByOther']").css("display","none");
            			tables.find("[data-field='CostByFishingShoot']").css("display","none");
            		},
            		page:false
                  });
                  return false;
            	}
        	//水浒传
        	if(data.index == 3){
        		table.reload('Alltable',{
            		where:{
            			room:$(".layui-tab-title .layui-this").attr("lay-id")
            		},
            		done:function(res){
            			var tables = $("#statRoom").next().find(".layui-table-box");
            			tables.find("[data-field='GainByFishingKill']").css("display","");
            			//水浒传获得
            			tables.find("[data-field='GainByFishingKill']").find("span")[0].innerHTML = "收分";
            			tables.find("[data-field='GainByFishingBonus']").css("display","");
            			//小玛丽获得 
            			tables.find("[data-field='GainByFishingBonus']").find("span")[0].innerHTML = "小玛丽获得";
            			tables.find("[data-field='GainByOther']").css("display","none");
            			tables.find("[data-field='CostByFishingShoot']").css("display","none");
            		},
            		page:false
                  });
                  return false;
            	}
        	//拉霸机
        	if(data.index == 4){
            		table.reload('Alltable',{
                		where:{
                			room:$(".layui-tab-title .layui-this").attr("lay-id")
                		},
                		done:function(res){
                			var tables = $("#statRoom").next().find(".layui-table-box");
                			tables.find("[data-field='GainByFishingKill']").css("display","");
                			//拉霸机获得
                			tables.find("[data-field='GainByFishingKill']").find("span")[0].innerHTML = "收分";
                			tables.find("[data-field='GainByFishingBonus']").css("display","");
                			//bonus获得 
                			tables.find("[data-field='GainByFishingBonus']").find("span")[0].innerHTML = "bonus奖励";
                			tables.find("[data-field='GainByOther']").css("display","");
                			tables.find("[data-field='GainByOther']").find("span")[0].innerHTML = "彩金池爆发";
                			tables.find("[data-field='CostByFishingShoot']").css("display","none");
                		},
                		page:false
                      });
                      return false;
              }
        });
      
        setInterval(function(){
        	table.reload('Alltable', {});
        },60000);
	  });
	</script>
	
</body>
</html>